def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]

input_str = input("Введите три слова: ").split()
if len(input_str) != 3:
    print("Wrong input")
else:
    number = ""
    for word in input_str:
        number += str(words.index(word))
    
    if len(number) != 3 or not number.isdigit():
        print("Wrong input")
    else:
        num = int(number)
        while not is_prime(num):
            num += 1
        print(num)
